<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${daoPackage}.${className}Dao">

    <insert id="Save" parameterType="${humpName}">
        insert into ${name} (<#list columns as column><#if column_index gt 0>,</#if>${column.name}</#list>)
        values(<#list columns as column><#if column_index gt 0>,</#if><#noparse>#</#noparse>{${column.humpName}}</#list>)
    </insert>

    <update id="Update" parameterType="${humpName}">
        update ${name}
        <trim prefix="set" suffixOverrides=",">
            <#list columns as column>
            <#if column.humpName != "id">
            <if test="${column.humpName} != null ">
                ${column.name} = <#noparse>#</#noparse>{${column.name}},
            </if>
            </#if>
            </#list>
        </trim>
        where id = <#noparse>#</#noparse>{id}
    </update>

    <delete id="Remove" parameterType="${humpName}">
        delete from ${name} where
        <trim prefix="" prefixOverrides="and|or">
            <#list columns as column>
            <if test="${column.humpName} != null ">
                and ${column.name} = <#noparse>#</#noparse>{${column.humpName}}
            </if>
            </#list>
        </trim>
    </delete>

    <select id="GetByKey" parameterType="integer" resultType="${humpName}" >
      select <#list columns as column> <#if column_index gt 0>,</#if> ${column.name} as ${column.humpName}</#list> from ${name}
       where id = <#noparse>#</#noparse>{id}
   </select>

    <select id="GetByVo" parameterType="${humpName}" resultType="${humpName}">
        select <#list columns as column> <#if column_index gt 0>,</#if> ${column.name} as ${column.humpName}</#list> from ${name}
        where
        <trim prefix="" prefixOverrides="and|or">
            <#list columns as column>
            <if test="${column.humpName} != null ">
                and ${column.name} = <#noparse>#</#noparse>{${column.humpName}}
            </if>
            </#list>
        </trim>
        limit 1
    </select>

    <select id="list" parameterType="${humpName}" resultType="${humpName}">
        select <#list columns as column> <#if column_index gt 0>,</#if> ${column.name} as ${column.humpName}</#list> from ${name}
        <trim prefix="where" prefixOverrides="and|or">
            <#list columns as column>
            <if test="${column.humpName} != null ">
                and ${column.name} = <#noparse>#</#noparse>{${column.humpName}}
            </if>
            </#list>
        </trim>
    </select>

    <select id="listMap" parameterType="map" resultType="hashMap">
        select <#list columns as column> <#if column_index gt 0>,</#if> a.${column.name} as ${column.humpName}</#list> from ${name} a
    </select>

</mapper>